package leetcode.linkedlist;

import leetcode.linkedlist.common.LinkedListUtils;
import leetcode.linkedlist.common.ListNode;

import java.util.List;

/**
 * Definition for singly-linked list.
 * public class ListNode {
 * int val;
 * ListNode next;
 * ListNode() {}
 * ListNode(int val) { this.val = val; }
 * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution92 {
    public ListNode reverseBetween(ListNode head, int left, int right) {
        return LinkedListUtils.reverseBetween(head, left, right);
    }
}

public class leetcode92 {
    public static void main(String[] args) {
        Solution92 solution92 = new Solution92();
        int[] nums = {1, 2, 3, 4, 5};
        test92(solution92, nums, 2, 4);
    }

    private static void test92(Solution92 solution92, int[] nums, int left, int right) {
        ListNode head = solution92.reverseBetween(LinkedListUtils.generateLinkedListByArray(nums), left, right);
        List<Integer> linkedListVals = LinkedListUtils.getLinkedListVals(head);
        System.out.println(linkedListVals);
    }


}
